package com.bigdata.booklibraryseatapi.controller;

import com.bigdata.booklibraryseatapi.common.pojo.PageResult;
import com.bigdata.booklibraryseatapi.service.IAreaService;
import com.bigdata.booklibraryseatapi.vo.req.AddAreaReqVO;
import com.bigdata.booklibraryseatapi.vo.req.EditAreaReqVO;
import com.bigdata.booklibraryseatapi.vo.req.PageAreaReqVO;
import com.bigdata.booklibraryseatapi.vo.req.RegisterReqVO;
import com.bigdata.booklibraryseatapi.vo.resp.AreaListRespVO;
import com.bigdata.booklibraryseatapi.vo.resp.PageAreaRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 区 前端控制器
 * </p>
 *
 * @author book
 * @since 2023-12-13
 */
@RestController
@RequestMapping("/api")
@Api(value = "AreaController",tags = {"图书馆区域接口"})
public class AreaController {

    @Resource
    private IAreaService iAreaService;

    @PostMapping("/admin/area/add")
    @ApiOperation(value = "区域添加接口")
    public void addArea(@RequestBody @Valid AddAreaReqVO vo) {
        iAreaService.addArea(vo);
    }


    @PostMapping("/admin/area/edit")
    @ApiOperation(value = "区域修改接口")
    public void editArea(@RequestBody @Valid EditAreaReqVO vo) {
        iAreaService.editArea(vo);
    }

    @PostMapping("/admin/area/list")
    @ApiOperation(value = "区域列表接口")
    public List<AreaListRespVO> getAreaList() {
        return iAreaService.getAreaList();
    }

    @PostMapping("/admin/area")
    @ApiOperation(value = "区域分页接口")
    public PageResult<PageAreaRespVO> pageArea(@RequestBody @Valid PageAreaReqVO vo) {
        return iAreaService.pageArea(vo);
    }
}
